package com.abbas.abchat.utils;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.abbas.abchat.db.Sqlite;

/**
 * @author abbas
 * @description: TODO
 * @date 2022/4/12 20:31
 */
public class SqlUtils {

    private SQLiteDatabase sqLiteDatabase;
    private Context mContext;

    public static final String RELATION_TABLE_HEADER = "rdb";
    public static final String CHAT_DB_HEADER = "cdb";

    public static SqlUtils getInstance(Context context) {
        return new SqlUtils(context);
    }

    public SqlUtils(Context mContext) {
        this.mContext = mContext;
        sqLiteDatabase = new Sqlite(mContext, Sqlite.DB_NAME, null, 1).getWritableDatabase();
    }

    public void execSQL(String sql) {
        sqLiteDatabase.execSQL(sql);
    }

    public void createRelationTable(long PId){
        String sql = "create table if not exists rdb"+PId+"(_id INTEGER not null primary key autoincrement,peopleId VARCHAR(40) unique,chatName VARCHAR(40) unique,lastContent Text,lastTime VARCHAR(40))";
        sqLiteDatabase.execSQL(sql);
    }

    public void createChatDb(int id,int Pid){
        String sql = "create table cdb"+ id + Pid +"(_id INTEGER not null primary key autoincrement,content Text,date VARCHAR(40),pId int,type int)";
        sqLiteDatabase.execSQL(sql);
    }


}
